﻿/// <reference path="jquery.js" />
/// <reference path="jquery-autologin.js "/>

// 为autologin主框架页面扩展Javascript对象
(function (window) {
    $$.frame = {
        extend: $.extend
    };

    window.$f = $$.frame;
})(window);

// 加载配置
$f.extend({
    loadConfig: function () {
        var me = this;
        $$.ajaxJson("config/config.js", function (json, error) {
            if (!json) {
                alert("加载配置文件出错，程序按默认配置运行。");
            } else if ($.isPlainObject(json)) {
                me.onLoadedConfig(json);
            }
        });
    },
    onLoadedConfig: function (config) {
        if (!!config.width && !!config.height) {
            window.resizeTo(config.width, config.height);
        }
    },
    config: function () {
        $($.proxy(this, "loadConfig"));
    }
});

// 控制布局
$f.extend({
    loadCss: function () {
        var dir = "";
        if ($.browser.msie) {
            if ($.browser.version.match(/^7\./)) {
                dir = "ie7";
            }
            if (!!dir) {
                dir = dir + "/";
            }
        }
        $("#css").attr("href", "styles/" + dir + "default.css");
    },

    onWindowResize: function () {
        var clientWidth = parseInt($("body").width(), 10);
        var clientHeight = parseInt($("#bottom_pane").position().top, 10);
        $("#middle_area").height(clientHeight - 95);
    },

    layout: function () {
        this.loadCss();
        var me = this;

        $(function () {
            $(window).resize($.proxy(me, "onWindowResize")).resize();
        })
    }
});

(function () {
    $f.config();
    $f.layout();

    $(function() {
        $("#wel_help").click(function() {
            window.open("help.html");
        });
    });
})();
